import {
	checkPermi,
	checkRole
} from "@/utils/permission"; // 权限判断函数
//权限菜单
let authMenuArr = [
	//安全目标
	{
		safetyTargetArr: [{
				title: '个人责任书下发',
				value: 'system:letter:page:distribute'
			},
			{
				title: '个人责任书签订',
				value: 'system:letter:page:sign'
			}
		]
	},
	//特殊作业
	{
		specialWorkArr: [{
				title: '作业管理',
				value: 'system:master:list'
			},
			{
				title: '作业清单',
				value: 'system:master:list'
			},
			{
				title: '作业统计',
				value: 'system:master:statistics'
			},

		]
	},
	//隐患管理
	{
		troubleArr: [{
				title: '定期排查',
				value: '',
				children: [{
						title: '我制定的',
						value: 'system:rectification:page',
					},
					{
						title: '我参与的',
						value: 'system:part:page',
					},
					{
						title: '我审批的',
						value: 'system:myExamine:page',
					},
					{
						title: '我签收的',
						value: 'system:mySign:page',
					},

				]
			},
			{
				title: '隐患整改',
				value: 'system:master:list'
			},
			{
				title: '全员排查',
				value: 'system:master:statistics'
			},

		]
	}
];
//安全目标
export function safeTargetMenu() {
	let isShow = checkPermi(['system:letter:page:distribute']) //责任书下发
	let isSign = checkPermi(['system:letter:page:sign']) //责任书签订
	if (isShow && isSign) {
		return {
			tabsActive: "个人责任书下发",
			tabsList: ["个人责任书下发", "个人责任书签订"]
		}
	} else if (isShow && !isSign) {
		return {
			tabsActive: "个人责任书下发",
			tabsList: ["个人责任书下发"]
		}
	} else if (!isShow && isSign) {
		return {
			tabsActive: "个人责任书签订",
			tabsList: ["个人责任书签订"]
		}
	}
}
//特殊作业
export function specialWorkMenu() {

	let isShow = checkPermi(['system:master:list']) //作业管理
	let isOrder = checkPermi(['system:master:order:list']) //作业清单
	let isStatistics = checkPermi(['system:master:statistics']) //作业统计

	if (isShow && isOrder && isStatistics) {
		return {
			tabsActive: "0",
			tabsList: ["作业管理", "作业清单", "作业统计"]
		}
	} else if (!isShow && isOrder || isStatistics) {
		return {
			tabsActive: "1",
			tabsList: ["作业清单", "作业统计"]
		}
	} else if (!isShow && !isOrder || "作业统计") {
		return {
			tabsActive: "2",
			tabsList: ["作业统计"]
		}
	}
}
//隐患排查
export function troubleMenu() {

	let isShow = checkPermi(['system:rectification:list']) //定期排查
	let isOrder = checkPermi(['system:troubleRect:list']) //隐患整改
	let isStatistics = checkPermi(['system:allShoot:list']) //全员排查
console.log("权限的bool", isShow, isOrder, isStatistics)
	if (isShow && isOrder && isStatistics) {
			// console.log("家来1", )
		return {
			tabsActive: 0,
			tabsList: ["定期排查", "隐患整改", "全员排查"]
		}
	} else if (!isShow && isOrder || isStatistics) {
			// console.log("家来2", )
		return {
			tabsActive: 1,
			tabsList: ["隐患整改", "全员排查"]
		}
	} else if (!isShow && !isOrder && isStatistics) {
		// console.log("家来3", )
		return {
			tabsActive: 2,
			tabsList: ["全员排查"]
		}
	} else if (!isShow && !isOrder && !isStatistics) {
		// console.log("家来4", )
		return {
			tabsActive: 5,
			tabsList: []
		}
	}
}
//隐患排查--定期排查
export function regularMenu() {

	let isShow = checkPermi(['system:rectification:page']) //我制定的
	let isOrder = checkPermi(['system:part:page']) //我参与的
	let isStatistics = checkPermi(['system:myExamine:page']) //我审批的
	let isSign = checkPermi(['system:mySign:page']) //我签收的


	if (isShow && isOrder && isStatistics && isSign) {
		return {
			tabsActive: 0,
			tabsList: ["我制定的", "我参与的", "我审批的", "我签收的"]
		}
	} else if (!isShow && isOrder || isStatistics || isSign) {
		return {
			tabsActive: 1,
			tabsList: ["我参与的", "我审批的", "我签收的"]
		}
	} else if (!isShow && !isOrder && isStatistics || isSign) {
		return {
			tabsActive: 2,
			tabsList: ["我审批的", "我签收的"]
		}
	} else if (!isShow && !isOrder && !isStatistics || isSign) {
		return {
			tabsActive: 3,
			tabsList: [ "我签收的"]
		}
	}
}

//隐患排查--隐患整改
export function manageMenu() {

	let isShow = checkPermi(['system:troubleIssue:page']) //隐患下发
	let isOrder = checkPermi(['system:planFeedBack:page']) //计划反馈
	let isStatistics = checkPermi(['system:troubleBack:page']) //整改反馈



	if (isShow && isOrder && isStatistics ) {
		return {
			tabsActive: 0,
			tabsList: ["隐患下发", "计划反馈", "整改反馈"]
		}
	} else if (!isShow && isOrder || isStatistics ) {
		return {
			tabsActive: 1,
			tabsList: ["计划反馈", "整改反馈"]
		}
	} else if (!isShow && !isOrder && isStatistics ) {
		return {
			tabsActive: 2,
			tabsList: ["整改反馈"]
		}
	} 
}

//隐患排查--全员排查
export function allShootMenu() {
	let isShow = checkPermi(['system:mysubmit:page']) //我提交的
	let isOrder = checkPermi(['system:examineManage:page']) //审核管理
	if (isShow && isOrder) {
		return {
			tabsActive: 0,
			tabsList: ["我提交的", "审核管理"]
		}
	} else if (!isShow || isOrder) {
		return {
			tabsActive: 1,
			tabsList: ["审核管理", ]
		}
	} 
}

//隐患排查--劳保管理
export function laobaoMenu() {
	let isShow = checkPermi(['system:materials:list']) //物资发放
	let isOrder = checkPermi(['system:person:list']) //个人签收
	if (isShow && isOrder) {
		return {
			tabsActive: 0,
			tabsList: ["物资发放", "个人签收"]
		}
	} else if (!isShow || isOrder) {
		return {
			tabsActive: 1,
			tabsList: ["个人签收", ]
		}
	} 
}